﻿// JavaScript Document
function selectDateMonth(obj, target) {
	var tid = $(target).attr("id");
	var str = $(target).val() + "-";
	//alert(str);
	var values = str.split("-");
	var panel = $(obj);
	var html = "";
	var d = new Date();
	var y = values[0] == "" ? d.getFullYear() : values[0];
	var mt = values[1] == "" ? (d.getMonth()+2)+'' : values[1];
	if(mt.substring(0,1) != 0 && mt.length == 1)
		mt = '0' + mt;
	target.attr("value", y + "-" + mt);
	html += '<select id="selectAccDateYear_'+tid+'">';
	for(var i = d.getFullYear()-10; i < d.getFullYear() + 5; i++) {
		html += '<option value="'+i+'"'+(y == i+"" ? " selected" : "")+'>' + i + '</option>';	
	}
	html += '</select>年<select id="selectAccDateMonth_'+tid+'">';
	for(var i = 1; i< 13; i++) {
		var m = i<10 ? '0' + i : i+"";
		html += '<option value="'+m+'"'+(m == mt ? " selected" : "")+'>'+m+'</option>';	
	}
	html += '</select>月';
	panel.html(html);
	$("#selectAccDateYear_"+tid).change(function(){
		target.attr("value", this.value + "-" + $("#selectAccDateMonth_"+tid).val());
	});
	$("#selectAccDateMonth_"+tid).change(function(){
		target.attr("value", $("#selectAccDateYear_"+tid).val() + "-" + this.value);
	});
}